package com.dp.appi.service.impl;

import com.dp.appi.dao.SysConfigDao;
import com.dp.appi.entity.UserEntity;
import com.dp.appi.service.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by chenghao on 2015/9/30.
 */
@Service
public class SysConfigServiceImpl implements SysConfigService {
    @Autowired
    private SysConfigDao sysConfigDao;

    @Override
    public List<Map<String, Object>> queryBaseConfig() {
        return sysConfigDao.findBaseConfig();
    }

    @Override
    public List<Map<String, Object>> getPayment() {
        return sysConfigDao.findPayment();
    }

    /**
     * 获取代码类型
     *
     * @param key
     * @return
     */
    @Override
    public List<Map<String, Object>> sysType(String key) {
        return sysConfigDao.sysType(key);
    }

    @Override
    public Map<String, Object> getSysArticleContent(Map<String, String> param) {
        return sysConfigDao.findSysArticleContent(param);
    }

    /**
     * 根据代码获取广告
     *
     * @param flag
     * @return
     */
    @Override
    public List<Map<String, Object>> getHomeAdvert(String flag) {
        return sysConfigDao.getHomeAdvert(flag);
    }

    /**
     * 离线地图配置
     *
     * @return
     */
    @Override
    public List<Map<String, Object>> offlineMap() {
        return sysConfigDao.offlineMap();
    }

    /**
     * 获取系统消息列表
     *
     * @param id
     */
    @Override
    public List<Map<String, Object>> sysMessList(String id,int s,int n) {
        return sysConfigDao.sysMessList(id,s,n);
    }

    /**
     * 根据openIdent获取userMap
     *
     * @param openIdent
     */
    @Override
    public Map<String, Object> getUserByOpenIdent(String openIdent) {
        UserEntity userEntity = UserEntity.decrypt(openIdent);
        return sysConfigDao.getUserByOpenIdent(userEntity.getA());
    }

    /**
     * 获取系统当前最新版本
     *
     * @return
     */
    @Override
    public Map<String, Object> getSysVersion(Integer soft_type) {
        return sysConfigDao.getSysVersion(soft_type);
    }
}
